package frame.laxcen.response;

import frame.laxcen.BaseFrame;
import frame.laxcen.dataobject.DataObject_0001_01;
import frame.laxcen.dataobject.DataObject_0010_0D;
import frame.laxcen.exception.IllegalFrameFormatException;
import frame.laxcen.response.annotation.FrameFeature;
import frame.laxcen.util.FrameReader;

import java.util.HashMap;
import java.util.Map;

// 配置读写器空闲模式返回值
@FrameFeature(MessageType = 0b0010, Mid = 0x0D)
public class Response_0010_0D extends BaseResponse {

    public Response_0010_0D(BaseFrame baseFrame) throws IllegalFrameFormatException {

        super(baseFrame);

        getContentMap().putAll(explainToMap());
    }

    @Override
    protected Map<String, String> analyzeResponse(FrameReader reader) throws IllegalFrameFormatException {

        Map<String, String> result = new HashMap<>();

        switch(reader.readU8()) {

            case 0: result.put("配置结果", "配置成功"); break;

            case 1: result.put("配置结果", "模式参数错误"); break;

            case 2: result.put("配置结果", "其他参数错误"); break;

            case 3: result.put("配置结果", "保存失败"); break;
        }

        return result;
    }

    public DataObject_0010_0D getDataObject() {

        return new DataObject_0010_0D(getContentMap());
    }
}
